package cn.miw.android.bdmp3.adapter;

import java.util.List;

import cn.miw.android.bdmp3.model.BaiDuListItem;
import cn.miw.android.bdmp3.service.Pub;
import cn.miw.android.bdmp3.service.Util;
import android.content.Context;
import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener;
import android.widget.Toast;

public class MenuListener implements OnMenuItemClickListener{

	private Context context;
	private List<BaiDuListItem>  rankLists;

	public MenuListener(Context context,List<BaiDuListItem>  rankLists) {
		super();
		this.context = context;
		this.rankLists = rankLists;
	}

	public boolean onMenuItemClick(MenuItem item) {
		int oldid = item.getItemId();
		int id = oldid / 100000;
		int pos = oldid - id * 100000;
		BaiDuListItem mp3 = rankLists.get(pos);
		switch (id) {
		case 10:
			Util.startDown(context, mp3);
			break;
		case 11:
			Pub.tryMusic(context, mp3);
			break;
		case 12:
			boolean x = Util.StartDownLRC(mp3);
			CharSequence hint = "";
			if (x) {
				hint = "开始下载歌词：" + mp3.getSinger() + "-" + mp3.getSong() + ".lrc";
			} else {
				hint = "该歌曲没有搜索到歌词。";
			}
			Toast.makeText(context, hint, 500).show();
			break;
		case 13:
//			shareTo("SINA", mp3.getSinger(), mp3.getSong());
			break;
		case 14:
//			shareTo("TENC", mp3.getSinger(), mp3.getSong());
			break;
		case 15:
//			shareTo("RENR", mp3.getSinger(), mp3.getSong());
			break;
		default:
			break;
		}
		return false;
	}
}
